import PureDevTeamDetail from '../components/dev-team-detail';
import * as DevTeamAction from 'actions/dev-team';
import { getFetchStatus } from 'actions/util';
import * as React from 'react';
import * as ReactRedux from 'react-redux';

const mapStateToProps = (state, ownProps) => {
  return {
    isFetching: getFetchStatus(state, DevTeamAction.getDetail),
    isTeamLeader: state.loginUser.hasRole('DEV_TEAM_LEADER', ownProps.id),
    detail: state.devTeamDetail
  };
};

class DevTeamDetail extends React.Component {
  componentDidMount() {
    this.props.dispatch(DevTeamAction.getDetail(this.props.id));
  }

  render() {
    return <PureDevTeamDetail {...this.props}/>;
  }
}

export default ReactRedux.connect(mapStateToProps)(DevTeamDetail);
